package com.ruoyi.business.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.TPotentialCustomerMapper;
import com.ruoyi.business.domain.TPotentialCustomer;
import com.ruoyi.business.service.ITPotentialCustomerService;
import com.ruoyi.common.core.text.Convert;

/**
 * 潜在客户Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-26
 */
@Service
public class TPotentialCustomerServiceImpl implements ITPotentialCustomerService 
{
    @Autowired
    private TPotentialCustomerMapper tPotentialCustomerMapper;

    /**
     * 查询潜在客户
     * 
     * @param id 潜在客户ID
     * @return 潜在客户
     */
    @Override
    public TPotentialCustomer selectTPotentialCustomerById(Long id)
    {
        return tPotentialCustomerMapper.selectTPotentialCustomerById(id);
    }

    /**
     * 查询潜在客户列表
     * 
     * @param tPotentialCustomer 潜在客户
     * @return 潜在客户
     */
    @Override
    public List<TPotentialCustomer> selectTPotentialCustomerList(TPotentialCustomer tPotentialCustomer)
    {
        return tPotentialCustomerMapper.selectTPotentialCustomerList(tPotentialCustomer);
    }

    /**
     * 新增潜在客户
     * 
     * @param tPotentialCustomer 潜在客户
     * @return 结果
     */
    @Override
    public int insertTPotentialCustomer(TPotentialCustomer tPotentialCustomer)
    {
        tPotentialCustomer.setCreateTime(DateUtils.getNowDate());
        tPotentialCustomer.setFollowUpUser(ShiroUtils.getUserId());
        return tPotentialCustomerMapper.insertTPotentialCustomer(tPotentialCustomer);
    }

    /**
     * 修改潜在客户
     * 
     * @param tPotentialCustomer 潜在客户
     * @return 结果
     */
    @Override
    public int updateTPotentialCustomer(TPotentialCustomer tPotentialCustomer)
    {
        return tPotentialCustomerMapper.updateTPotentialCustomer(tPotentialCustomer);
    }

    /**
     * 删除潜在客户对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTPotentialCustomerByIds(String ids)
    {
        return tPotentialCustomerMapper.deleteTPotentialCustomerByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除潜在客户信息
     * 
     * @param id 潜在客户ID
     * @return 结果
     */
    @Override
    public int deleteTPotentialCustomerById(Long id)
    {
        return tPotentialCustomerMapper.deleteTPotentialCustomerById(id);
    }

    @Override
    public List<TPotentialCustomer> selectTPotentialCustomerByUser(TPotentialCustomer userId) {
        userId.setUserId(ShiroUtils.getUserId().toString());
        return tPotentialCustomerMapper.selectTPotentialCustomerByUser( userId );
    }

    @Override
    public void updata(TPotentialCustomer tp) {
        tPotentialCustomerMapper.updata(tp);
    }

    @Override
    public int selectTPotentialCustomerByPhone(TPotentialCustomer tPotentialCustomer) {
       int count= tPotentialCustomerMapper.selectTPotentialCustomerByPhone(tPotentialCustomer);
        return count;
    }
}
